package br.com.mestrefamiliar.mestres;

import java.util.List;

import org.hibernate.Session;

public class MestresDAOHibernate implements MestresDAO {
	
	private Session session;
	
	public void setSession(Session session){
		this.session = session;
	}

	@Override
	public void salvar(Mestres mestre) {
		this.session.saveOrUpdate(mestre);
		
	}

	@Override
	public void excluir(Mestres mestre) {
		this.session.delete(mestre);
		
	}

	@Override
	public Mestres carregar(Integer codigo) {
		return (Mestres) this.session.get(Mestres.class, codigo);
		
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Mestres> lista() {
		return this.session.createCriteria(Mestres.class).list();
	}

}
